package com.hlf.eduservice.controller;


import com.atguigu.commonutils.R;
import com.hlf.eduservice.entity.EduVideo;
import com.hlf.eduservice.service.EduVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author hlf
 * @since 2022-11-27
 */
@RestController
@RequestMapping("/eduservice/video")
@CrossOrigin
public class EduVideoController {
    @Autowired
    private EduVideoService videoService;

    // 添加小节
     @PostMapping("addVideo")
    public R addVideo(@RequestBody EduVideo eduVideo){
         videoService.save(eduVideo);
         return R.ok();
     }

    // 删除小节
    //todo 删除小节时候同时删除视频
    @DeleteMapping("{id}")
    public R deleteVideo(@PathVariable String id){
         videoService.removeById(id);
         return R.ok();
    }
    // 修改小节
     @PostMapping("updateVideo")
    public R updateVideo(@RequestBody EduVideo eduVideo){
         videoService.updateById(eduVideo);
         return R.ok();
     }



}

